package com.foosun.service;

import java.io.IOException;

import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.foosun.util.wechat.WxCommonUtils;

@Service
public class WxAccessTokenService {
	
	@Cacheable(value="accessTokenCache", key="#id") 
	public String get(String id) throws IOException {
		return WxCommonUtils.getAccessToken(id);
	}
	
	@CacheEvict(value="accessTokenCache", key="#id")
	public void clear(String id) {
		System.out.println("Remove the appId["+id+"] related cache.");
	}
}
